package itesm.coler.data;

import java.sql.SQLException;
import java.util.ArrayList;

import itesm.coler.models.Team;

public interface TeamDAO {

	/**
     * Returns the team from the database matching the given id, otherwise null.
     * @param courseId: The id of the course to be returned.
     * @return The course from the database matching the given id, otherwise null.
     * @throws DAOException If something fails at database level.
     */
    public Team findTeamById(int teamId) throws DAOException;
    
    /**
     * Returns a list of all teams from the database ordered by teamId. The list is never null and
     * is empty when the database does not contain any team.
     * @return A list of all teams from the database ordered by teamid.
     * @throws DAOException If something fails at database level.
     */
	public ArrayList<Team> findAll() throws DAOException, SQLException;
	
	  /**
     * Returns a list of all teams from the database of a given course ordered by teamId. The list is never null and
     * is empty when the database does not contain any team.
     * @param courseId: The course courseId of the teams searched.
     * @return A list of all teams of a given course from the database ordered by teamID.
     * @throws DAOException If something fails at database level.
     */
    public ArrayList<Team> findAllByCourse(String courseId) throws DAOException;
    
    /**
     * Create the given team in the database. The teamid must be unique, otherwise it will throw
     * IllegalArgumentException.  
     * @param team The team to be created in the database.
     * @throws IllegalArgumentException If the teamid exists
     * @throws DAOException If something fails at database level.
     */
	  public int insertTeam(Team team) throws IllegalArgumentException, DAOException;
	  
	  /**
	     * Update the given team in the database. The teamid must not be null, otherwise it will throw
	     * IllegalArgumentException.
	     * @param team The team to be updated in the database.
	     * @throws IllegalArgumentException If the teamid is null.
	     * @throws DAOException If something fails at database level.
	     */
	  public boolean updateTeam(Team team) throws DAOException;
	  
	  /**
	     * Delete the given course from the database. 
	     * @param team The team to be deleted from the database.
	     * @throws DAOException If something fails at database level.
	     */
	  public boolean deleteTeam(int teamId) throws DAOException;
	  
	  /**
	     * Change the team's active status
	     * @param teamId The teamId which is to be checked in the database.
	     * @param status The active status: 1 active, 0 not active
	     * @throws DAOException If something fails at database level.
	     */
	  public boolean updateTeamActiveStatus(int teamId, boolean status) throws DAOException;

}